package com.rielt.mvc;

import com.rielt.entity.Building;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created with IntelliJ IDEA.
 * User: Redactor
 * Date: 23.12.13
 * Time: 21:28
 * To change this template use File | Settings | File Templates.
 */

@Controller
@RequestMapping("/building")
public class BuilderController {

    @RequestMapping(value = "/new", method = RequestMethod.GET)
    public String showForm(ModelMap model) {
        return "addBuilding";
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String add(ModelMap model,
                      @RequestParam(value = "country", required = false) String country,
                      @RequestParam(value = "city", required = false) String city,
                      @RequestParam(value = "address", required = false) String address) {
        Building building = new Building();
        building.setAddress(address);
        building.setCity(city);
        building.setCountry(country);
        return "addBuilding";
    }

}
